﻿@{
    ViewBag.Title = "Search";
}

<div id="body">
    @using (Html.BeginForm("Suggest", "Home", FormMethod.Get, new { target = "_blank" }))
    {
        <div style="width:955px;margin:auto;">
            <label for="tags">Tìm mọi thứ: </label>
            <input id="tags" type="text" name ="input">
            <input name="enter" type="hidden" value="true"/>
            <input id="search" type="submit" value="Tìm" />
        </div>
    }
</div>
@section scripts{
    <script>
        var availableTags = [
          "ActionScript",
          "AppleScript",
          "Asp",
          "BASIC",
          "C",
          "C++",
          "Clojure",
          "COBOL",
          "ColdFusion",
          "Erlang",
          "Fortran",
          "Groovy",
          "Haskell",
          "Java",
          "JavaScript",
          "Lisp",
          "Perl",
          "PHP",
          "Python",
          "Ruby",
          "Scala",
          "Scheme"
        ];


        $(function () {

            $("#tags").autocomplete({
                minLength: 2,
                source: function (request, response) {
                    $.ajax({
                        type: "GET",
                        url: '@Url.Action("Suggest")',
                        data: { input: $('#tags').val() },
                        dataType: "json",
                        success: function (data) {
                            response(data);
                        }
                    });
                }
            })
        });
    </script>
}
